﻿
    using Maticsoft.BLL;
    using Maticsoft.Model;

    using System;
    using System.Text;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;

    public partial class WebPage_DiaoCha_Wenti_Xuanxiang_Bianji : SystemBBasePage
    {
       
        private Maticsoft.BLL.vote_options vops = new Maticsoft.BLL.vote_options();
        private Maticsoft.BLL.vote_question voqs = new Maticsoft.BLL.vote_question();

        private void getEdit()
        {
            Maticsoft.Model.vote_question model = new Maticsoft.Model.vote_question();
            Maticsoft.Model.vote_options _options = new Maticsoft.Model.vote_options();
            StringBuilder builder = new StringBuilder();
            StringBuilder builder2 = new StringBuilder();
            StringBuilder builder3 = new StringBuilder();
            StringBuilder builder4 = new StringBuilder();
            StringBuilder builder5 = new StringBuilder();
            if (base.Request.QueryString["question_id"] != null)
            {
                model = this.voqs.GetModel(Convert.ToInt32(base.Request.QueryString["question_id"].ToString()));
                if (model != null)
                {
                    builder4.Append("   <h2>'" + model.Title + "</h2>");
                }
                builder5.Append("<input type='hidden' name='question_id' value='" + base.Request.QueryString["question_id"] + "' />");
            }
            if (base.Request.QueryString["id"] != null)
            {
                _options = this.vops.GetModel(Convert.ToInt32(base.Request.QueryString["id"].ToString()));
                if (_options != null)
                {
                    this.name.Value = _options.name;
                    if (_options.is_br == 1)
                    {
                        builder.Append("<input type='radio' name='is_br' value='1' checked />换行");
                        builder.Append("<input type='radio' name='is_br' value='0' />不换行");
                    }
                    else
                    {
                        builder.Append("<input type='radio' name='is_br' value='1' />换行");
                        builder.Append("<input type='radio' name='is_br' value='0' checked />不换行");
                    }
                    if (_options.is_input == 1)
                    {
                        builder2.Append("<input type='radio' name='is_input' value='1' checked />有");
                        builder2.Append(" <input type='radio' name='is_input' value='0' />无");
                    }
                    else
                    {
                        builder2.Append("<input type='radio' name='is_input' value='1' />有");
                        builder2.Append(" <input type='radio' name='is_input' value='0' checked/>无");
                    }
                    if (_options.is_show == 1)
                    {
                        builder3.Append(" <input type='radio' name='is_show' value='1' checked/>显示");
                        builder3.Append(" <input type='radio' name='is_show' value='0' />隐藏");
                    }
                    else
                    {
                        builder3.Append(" <input type='radio' name='is_show' value='1' />显示");
                        builder3.Append(" <input type='radio' name='is_show' value='0' checked/>隐藏");
                    }
                    this.ordername.Value = _options.order.ToString();
                    builder5.Append("<input type='hidden' name='options_id' value='" + base.Request.QueryString["id"] + "' />");
                }
            }
            this.bianji.Text = builder4.ToString();
            this.Literal1.Text = builder.ToString();
            this.Literal2.Text = builder2.ToString();
            this.Literal3.Text = builder3.ToString();
            this.Literal4.Text = builder5.ToString();
        }

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            this.HeaderControl1.Select = "diaocha";
            this.DiaoCha1.Select = "Wenti";
            if (!base.IsPostBack)
            {
                this.getEdit();
            }
            if (base.Request.HttpMethod == "POST")
            {
                this.setEdit();
            }
        }

        private void setEdit()
        {
            Maticsoft.Model.vote_options model = new Maticsoft.Model.vote_options();
            model.id = int.Parse(base.Request.Form["options_id"].ToString());
            model.question_id = int.Parse(base.Request.Form["question_id"].ToString());
            model.name = this.name.Value;
            model.is_br = int.Parse(base.Request.Form["is_br"].ToString());
            model.is_input = int.Parse(base.Request.Form["is_input"].ToString());
            model.is_show = int.Parse(base.Request.Form["is_show"].ToString());
            this.vops.Update(model);
            base.Response.Redirect("DiaoCha_Wenti_Xuanxiang.aspx?id=" + base.Request.Form["question_id"].ToString());
        }
    }



